import {response} from "express";

import {chatRoomList, allChatRecords, insertMessage} from "./ChatRoomList.js";
import {getMomentList} from './momentData.js'


const resWrapper = (data) => {
    return {
        status: 200,
        data: data,
        message: ''
    }
}

export default [
    // 登录接口
    {  
        url: '/api/user/login', 
        method: 'post',
        handler: ()=> {
            return resWrapper(
                {
                    token: '123456',
                    userInfo: {
                        username: '你的头发乱了哦',
                        actvator: 'https://img.cehca.com/uploadimg/image/20191211/20191211165827_77774.jpg',
                    },
                    momentInfo: {
                        bg: 'https://img1.baidu.com/it/u=3583517881,2229239907&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=800',
                        message: '宁可教负天下人'
                    }
                }
            )
        }
    },
    // 未读消息接口
    {  
        url: '/api/user/noReadMessage',
        method: 'post',
        handler: ()=> {
            return resWrapper(
                {
                    message: 10,
                    moment: 2
                }
            )
        }
    },
    // 获取所有的当前聊天室（个人+群）
    {  
        url: '/api/user/chatRoomList',
        method: 'post',
        handler: ()=> {
            return resWrapper(
                {
                    data: chatRoomList(),
                    next: false
                }
            )
        }
    },
    // 获取所有聊天记录
    {  
        url: '/api/user/allChatRecords',
        method: 'post',
        handler: ()=> {
            return resWrapper(
                {
                    data: allChatRecords(),
                    next: false
                }
            )
        }
    },
    // 发送消息
    {  
        url: '/api/message/insertMessage',
        method: 'post',
        handler: (params)=> {
            return resWrapper(insertMessage(params.roomId, params.message, params.sendName))
        }
    },
    // 获取朋友圈动态
    {  
        url: '/api/moment/momentList',
        method: 'post',
        handler: (params)=> {
            console.log(params)
            return resWrapper({list: getMomentList(params.start, params.pos), next: true})
        }
    },
]